package com.furnitur.modules.portal.controller;


import com.furnitur.common.api.Result;
import com.furnitur.modules.portal.dto.payment.PaymentDTO;
import com.furnitur.modules.portal.service.PortalPaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Map;

@RestController
@RequestMapping("/api/portal/payment")
public class PortalPaymentController {
    
    @Autowired
    private PortalPaymentService paymentService;
    
    @PostMapping("/create")
    public Result<Map<String, Object>> createPayment(@Valid @RequestBody PaymentDTO paymentDTO) {
        return Result.success(paymentService.createPayment(paymentDTO));
    }
    
    @GetMapping("/status/{orderNo}")
    public Result<Integer> queryPaymentStatus(@PathVariable String orderNo) {
        return Result.success(paymentService.queryPaymentStatus(orderNo));
    }
    
    @PostMapping("/mock/callback/{orderNo}")
    public Result<Void> mockPaymentCallback(@PathVariable String orderNo) {
        paymentService.mockPaymentCallback(orderNo);
        return Result.success();
    }
} 